﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace InterfaceFiles
{
  public class XPSWMM10InterfaceReader : IInterfaceReader, IDisposable
  {
    FileStream fileStream;
    BinaryReader reader;

    public XPSWMM10InterfaceReader(string fileName)
    {
      fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read,
        FileShare.Read);
      reader = new BinaryReader(fileStream);
    }

    public string FileName
    {
      get;
      set;
    }

    public int ReadInt()
    {
      int buffer = reader.ReadInt32();
      return buffer;
    }

    public string ReadString(int length)
    {
      char[] buffer = new char[length];
      buffer = reader.ReadChars(length);
      return new string(buffer);
    }

    public double ReadDouble()
    {
      double buffer = reader.ReadDouble();
      return buffer;
    }

    public void Dispose()
    {
      reader.Close();
      reader.Dispose();
      fileStream.Close();
      fileStream.Dispose();
    }

    public bool IsEndOfFile
    {
      get { return reader.PeekChar() == -1; }
    }

    public void Close()
    {
      reader.Close();
    }
  }
}
